package com.ibeeking.found.common.config.feign.fallback;

import com.ibeeking.found.common.config.feign.MarketingJobFeignClient;
import com.ibeeking.found.common.entity.TimeTaskJobParam;
import com.ibeeking.nematos.utils.result.ResponseCodeEnum;
import com.ibeeking.nematos.utils.result.ResponseResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 降级工场
 *
 * @Author ibeeking
 * @date 2019/1/18
 */
@Component
public class MarketingJobFeignClientFallbackFactory implements FallbackFactory<MarketingJobFeignClient> {
    @Override
    public MarketingJobFeignClient create(Throwable throwable) {
        return new MarketingJobFeignClient() {
            @Override
            public ResponseResult<Boolean>  createJobInfoForUpdateGroupCouponStatus(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，创建券包状态更新Job任务ID失败。" + throwable.getMessage(), true);
            }

            @Override
            public  ResponseResult<Boolean>  delJobInfoForUpdateGroupCouponStatus(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，删除券包状态更新Job任务ID失败。" + throwable.getMessage(), true);
            }
            @Override
            public ResponseResult<Boolean>  createJobInfoForClearExpiredCoupon(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，创建每日清理过期会员优惠券Job任务ID失败。" + throwable.getMessage(), true);
            }

            @Override
            public  ResponseResult<Boolean>  delJobInfoForClearExpiredCoupon(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，删除每日清理过期会员优惠券Job任务ID失败。" + throwable.getMessage(), true);
            }
            @Override
            public ResponseResult<Boolean>  createJobInfoForClearExpiredCampaign(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，创建每日清理过期活动Job任务ID失败。" + throwable.getMessage(), true);
            }

            @Override
            public  ResponseResult<Boolean>  delJobInfoForClearExpiredCampaign(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，删除每日清理过期Job任务ID失败。" + throwable.getMessage(), true);
            }
            @Override
            public ResponseResult<Boolean>  createJobInfoForCrowdOperatePlan(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，创建人群运营Job任务ID失败。" + throwable.getMessage(), true);
            }

            @Override
            public  ResponseResult<Boolean>  delJobInfoForCrowdOperatePlan(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，删除人群运营Job任务ID失败。" + throwable.getMessage(), true);
            }
            @Override
            public ResponseResult<Boolean>  createJobInfoForSceneMarketingPlan(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，创建场景营销Job任务ID失败。" + throwable.getMessage(), true);
            }

            @Override
            public  ResponseResult<Boolean>  delJobInfoForSceneMarketingPlan(TimeTaskJobParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，删除场景营销Job任务ID失败。" + throwable.getMessage(), true);
            }

        };
    }
}
